#pragma once
#include "RedBlackTree.h"
namespace mymap
{
	template<class K,class V>
	class  map
	{
	public:	
		
		struct MapofKey
		{
			const K operator()(const pair<K, V> kv)
			{
				return kv.first;
			}
		};
		typedef typename RBTree<K, pair<const K, V>, MapofKey>::Iterator iterator;
		typedef typename RBTree<K, pair<const K, V>, MapofKey>::Const_Iterator const_iterator;
	private:
		typedef RBTree<K, pair<const K, V> , MapofKey> RB_Tree;
	public:
		iterator begin()
		{
			return _t.Begin();
		}
		iterator end()
		{
			return _t.End();
		}
		const_iterator begin() const
		{
			return _t.Begin();
		}
		const_iterator end() const
		{
			return _t.End();
		}
		pair<iterator, bool> insert(const pair<const K,V>& kv)
		{
			return _t.insert(kv);
		}
		V& operator[](const K& key)
		{
			pair<iterator, bool> ret = insert(make_pair(key, V()));
			return (ret.first)->second;
		}
		void inorder()
		{
			_t.InOrder();
			cout << endl;
		}
	private:
		RB_Tree _t;
	};
}